import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:ichinesereader/constants.dart';
import 'package:ichinesereader/controller/cache.dart';
import 'package:ichinesereader/models/book/Options.dart';
import 'package:ichinesereader/models/forms/forms.dart';
import 'package:ichinesereader/models/report/classOverviewTotal.dart';
import 'package:ichinesereader/pages/teacher/reportsBasket.dart';
import 'package:ichinesereader/pages/teacher/reportsHomework.dart';
import 'package:ichinesereader/pages/teacher/reportsStudent.dart';
import 'package:ichinesereader/utils/log.dart';
import 'package:intl/intl.dart';
import 'package:reactive_forms/reactive_forms.dart';
import '../../../themes/appTheme.dart';

class ClassReportOverallData extends StatefulWidget {
  ClassReportOverallData({
    Key? key,
    Options? this.selectedTime,
    Function? this.updateSelectedTime,
    String? this.startTime,
    String? this.endTime,
    Function? this.updateCustomTime,
    ClassOverviewTotalData? this.classOverviewTotalData,
  }) : super(key: key);

  final selectedTime;
  final updateSelectedTime;
  final startTime;
  final endTime;
  final updateCustomTime;
  final classOverviewTotalData;

  @override
  _ClassReportOverallData createState() => _ClassReportOverallData();
}

class _ClassReportOverallData extends State<ClassReportOverallData> {
  final formModel = FromAndToModel();
  late FormGroup form;
  var box = Hive.box('appconfig');
  bool isTeacher = false;

  @override
  void initState() {
    form = this.formModel.form;
    form.control('from').value = null;
    form.control('to').value = null;
    isTeacher = box.get(CacheManagerKey['nanhairole'].toString()) ==
        Constants.NanhaiRole_Teacher;
    super.initState();
  }

  void _onCustomTimeUpdate() {
    Log.debug("form.valid=${form.valid} form.value=${form.value}");
    if (!form.valid) {
      form.markAllAsTouched();
      return;
    }
    var tempStartTime =
        DateFormat('MM/dd/yyyy').format(form.control("from").value);
    var tempEndTime = DateFormat('MM/dd/yyyy').format(form.control("to").value);
    widget.updateCustomTime(tempStartTime, tempEndTime);
  }

  @override
  Widget build(BuildContext context) {
    Log.debug('build common report class report overall data');
    final isSmallScreen =
        MediaQuery.of(context).size.width < Constants.DefinedScreenSmallSize;

    return Container(
      //margin: EdgeInsets.symmetric(vertical: 12.0),
      child: (Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            children: [
              DropdownButton(
                dropdownColor: Get.isDarkMode
                    ? AppTheme.colors.darkTheme4
                    : Get.theme.primaryColor,
                icon: Icon(
                  Icons.arrow_drop_down_outlined,
                  color: Get.isDarkMode
                      ? Get.theme.primaryColorDark
                      : Colors.black,
                ),
                value: widget.selectedTime,
                items: Constants.timeRanges.map((value) {
                  return DropdownMenuItem(
                    value: value,
                    child: Text(
                      value.label.toString(),
                      style: TextStyle(
                          fontSize: 15.0,
                          color: Get.isDarkMode
                              ? Get.theme.primaryColorDark
                              : Get.theme.primaryColorLight),
                      overflow: TextOverflow.fade,
                    ),
                  );
                }).toList(),
                onChanged: (value) {
                  value as Options;
                  widget.updateSelectedTime(value);
                  switch (value.value) {
                    case 0:
                      widget.updateCustomTime(null, null);
                      break;
                    case '*':
                      break;
                    default:
                      int timeDiff =
                          (value.value == null ? 0 : value.value) * -1;
                      var tempStartTime = DateFormat('MM/dd/yyyy')
                          .format(DateTime.now().add(Duration(days: timeDiff)));
                      var tempEndTime =
                          DateFormat('MM/dd/yyyy').format(DateTime.now());

                      widget.updateCustomTime(tempStartTime, tempEndTime);
                  }
                  form.control('from').value = null;
                  form.control('to').value = null;
                },
              ),
              widget.selectedTime != null && widget.selectedTime.value == "*"
                  ? Expanded(
                      child: ReactiveForm(
                      formGroup: form,
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceAround,
                        children: <Widget>[
                          Flexible(
                            child: ReactiveTextField<DateTime>(
                              formControlName: 'from',
                              //readOnly: true,
                              decoration: InputDecoration(
                                labelText: 'From'.tr,
                                labelStyle:
                                    Theme.of(context).textTheme.titleSmall,
                                suffixIcon: ReactiveDatePicker<DateTime>(
                                  formControlName: 'from',
                                  firstDate: DateTime(1990),
                                  lastDate: widget.endTime != null
                                      ? DateFormat('MM/dd/yyyy')
                                          .parse(widget.endTime)
                                      : DateTime.now(),
                                  builder: (context, picker, child) {
                                    return IconButton(
                                      onPressed: picker.showPicker,
                                      icon: const Icon(Icons.date_range),
                                    );
                                  },
                                ),
                              ),
                            ),
                          ),
                          Flexible(
                            child: ReactiveTextField<DateTime>(
                              formControlName: 'to',
                              //readOnly: true,
                              decoration: InputDecoration(
                                labelText: 'To'.tr,
                                labelStyle:
                                    Theme.of(context).textTheme.titleSmall,
                                suffixIcon: ReactiveDatePicker<DateTime>(
                                  formControlName: 'to',
                                  firstDate: widget.startTime != null
                                      ? DateFormat('MM/dd/yyyy')
                                          .parse(widget.startTime)
                                          .add(const Duration(days: 1))
                                      : DateTime(1990),
                                  lastDate: DateTime.now(),
                                  builder: (context, picker, child) {
                                    return IconButton(
                                      onPressed: picker.showPicker,
                                      icon: const Icon(Icons.date_range),
                                    );
                                  },
                                ),
                              ),
                            ),
                          ),
                          ReactiveFormConsumer(
                            builder: (context, form, child) {
                              return ElevatedButton(
                                  child: Text('Go'.tr),
                                  onPressed: _onCustomTimeUpdate);
                            },
                          ),
                        ],
                      ),
                    ))
                  : Text(""),
              Expanded(
                  child: widget.startTime != null && widget.endTime != null
                      ? Text(
                          "  ** Showing report from ${widget.startTime}(UTC) to ${widget.endTime}(UTC)")
                      : Text("")),
              Spacer(),
            ],
          ),
          widget.classOverviewTotalData != null &&
                  widget.classOverviewTotalData.result != null &&
                  widget.classOverviewTotalData.result.studentNum != null
              ? Container(
                  child: isSmallScreen
                      ? Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Expanded(
                                  child: GestureDetector(
                                    onTap: () {
                                      if (isTeacher) {
                                        Get.toNamed('/teacher/students');
                                      }
                                    },
                                    child: Container(
                                      margin: EdgeInsets.all(3.0),
                                      padding: EdgeInsets.symmetric(
                                          horizontal: 21.0, vertical: 6.0),
                                      decoration: BoxDecoration(
                                          color: Get.isDarkMode
                                              ? AppTheme.colors.darkTheme2
                                              : Colors.white.withOpacity(0.6),
                                          borderRadius:
                                              BorderRadius.circular(3.0)),
                                      child: Column(
                                        children: [
                                          Container(
                                            margin: EdgeInsets.symmetric(
                                                vertical: 6.0),
                                            padding: EdgeInsets.symmetric(
                                                horizontal: 9.0),
                                            decoration: BoxDecoration(
                                                color: Get.isDarkMode
                                                    ? Colors.black
                                                    : Colors.black
                                                        .withOpacity(0.1),
                                                borderRadius:
                                                    BorderRadius.circular(
                                                        30.0)),
                                            child: Text(
                                              "Students".tr,
                                              maxLines: 1,
                                              overflow: TextOverflow.fade,
                                              softWrap: false,
                                              style: TextStyle(
                                                color: Get.isDarkMode
                                                    ? Get.theme.primaryColorDark
                                                    : Colors.black,
                                                fontSize: 12.0,
                                              ),
                                            ),
                                          ),
                                          Text(
                                            widget.classOverviewTotalData.result
                                                .studentNum
                                                .toString(),
                                            style: TextStyle(
                                              decoration:
                                                  TextDecoration.underline,
                                              color: Get.isDarkMode
                                                  ? Get.theme.primaryColorDark
                                                  : Colors.black,
                                              fontSize: 30.0,
                                            ),
                                          )
                                        ],
                                      ),
                                    ),
                                  ),
                                ),
                                Expanded(
                                  child: GestureDetector(
                                    onTap: () {
                                      if (isTeacher) {
                                        Get.to(() => TeacherReportsHomework(
                                            showAppbar: true));
                                        // Get.toNamed(
                                        //     '/teacher/reports/homework');
                                      }
                                    },
                                    child: Container(
                                      margin: EdgeInsets.all(3.0),
                                      padding: EdgeInsets.symmetric(
                                          horizontal: 18.0, vertical: 6.0),
                                      decoration: BoxDecoration(
                                          color: Get.isDarkMode
                                              ? AppTheme.colors.darkTheme2
                                              : Colors.white.withOpacity(0.6),
                                          borderRadius:
                                              BorderRadius.circular(3.0)),
                                      child: Column(
                                        children: [
                                          Container(
                                            margin: EdgeInsets.symmetric(
                                                vertical: 6.0),
                                            padding: EdgeInsets.symmetric(
                                                horizontal: 9.0),
                                            decoration: BoxDecoration(
                                                color: Get.isDarkMode
                                                    ? Colors.black
                                                    : Colors.black
                                                        .withOpacity(0.1),
                                                borderRadius:
                                                    BorderRadius.circular(
                                                        30.0)),
                                            child: Text(
                                              "Homework".tr,
                                              maxLines: 1,
                                              overflow: TextOverflow.fade,
                                              softWrap: false,
                                              style: TextStyle(
                                                color: Get.isDarkMode
                                                    ? Get.theme.primaryColorDark
                                                    : Colors.black,
                                                fontSize: 12.0,
                                              ),
                                            ),
                                          ),
                                          Text(
                                            widget.classOverviewTotalData.result
                                                .assignments
                                                .toString(),
                                            style: TextStyle(
                                              decoration:
                                                  TextDecoration.underline,
                                              color: Get.isDarkMode
                                                  ? Get.theme.primaryColorDark
                                                  : Colors.black,
                                              fontSize: 30.0,
                                            ),
                                          ),
                                        ],
                                      ),
                                    ),
                                  ),
                                ),
                                Expanded(
                                  child: GestureDetector(
                                    onTap: () {
                                      if (isTeacher) {
                                        // Get.toNamed('/teacher/reports/student');
                                         Get.to(() => TeacherReportsStudent(showAppbar: true));
                                      }
                                    },
                                    child: Container(
                                      margin: EdgeInsets.all(3.0),
                                      padding: EdgeInsets.symmetric(
                                          horizontal: 21.0, vertical: 6.0),
                                      decoration: BoxDecoration(
                                          color: Get.isDarkMode
                                              ? AppTheme.colors.darkTheme2
                                              : Colors.white.withOpacity(0.6),
                                          borderRadius:
                                              BorderRadius.circular(3.0)),
                                      child: Column(
                                        children: [
                                          Container(
                                            margin: EdgeInsets.symmetric(
                                                vertical: 6.0),
                                            padding: EdgeInsets.symmetric(
                                                horizontal: 9.0),
                                            decoration: BoxDecoration(
                                                color: Get.isDarkMode
                                                    ? Colors.black
                                                    : Colors.black
                                                        .withOpacity(0.1),
                                                borderRadius:
                                                    BorderRadius.circular(
                                                        30.0)),
                                            child: Text(
                                              "Books Read".tr,
                                              maxLines: 1,
                                              overflow: TextOverflow.fade,
                                              softWrap: false,
                                              style: TextStyle(
                                                color: Get.isDarkMode
                                                    ? Get.theme.primaryColorDark
                                                    : Colors.black,
                                                fontSize: 12.0,
                                              ),
                                            ),
                                          ),
                                          Text(
                                            widget.classOverviewTotalData.result
                                                .readTimes
                                                .toString(),
                                            style: TextStyle(
                                              decoration:
                                                  TextDecoration.underline,
                                              color: Get.isDarkMode
                                                  ? Get.theme.primaryColorDark
                                                  : Colors.black,
                                              fontSize: 30.0,
                                            ),
                                          )
                                        ],
                                      ),
                                    ),
                                  ),
                                )
                              ],
                            ),
                            Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Expanded(
                                  child: GestureDetector(
                                    onTap: () {
                                      if (isTeacher) {
                                         // Get.toNamed('/teacher/reports/student');
                                         Get.to(() => TeacherReportsStudent(showAppbar: true));
                                      }
                                    },
                                    child: Container(
                                      margin:
                                          EdgeInsets.symmetric(horizontal: 3.0),
                                      padding: EdgeInsets.symmetric(
                                          horizontal: 21.0, vertical: 6.0),
                                      decoration: BoxDecoration(
                                          color: Get.isDarkMode
                                              ? AppTheme.colors.darkTheme2
                                              : Colors.white.withOpacity(0.6),
                                          borderRadius:
                                              BorderRadius.circular(3.0)),
                                      child: Column(
                                        children: [
                                          Container(
                                            margin: EdgeInsets.symmetric(
                                                vertical: 6.0),
                                            padding: EdgeInsets.symmetric(
                                                horizontal: 9.0),
                                            decoration: BoxDecoration(
                                                color: Get.isDarkMode
                                                    ? Colors.black
                                                    : Colors.black
                                                        .withOpacity(0.1),
                                                borderRadius:
                                                    BorderRadius.circular(
                                                        30.0)),
                                            child: Text(
                                              "Titles Read".tr,
                                              maxLines: 1,
                                              overflow: TextOverflow.fade,
                                              softWrap: false,
                                              style: TextStyle(
                                                color: Get.isDarkMode
                                                    ? Get.theme.primaryColorDark
                                                    : Colors.black,
                                                fontSize: 12.0,
                                              ),
                                            ),
                                          ),
                                          Text(
                                            widget.classOverviewTotalData.result
                                                .readBooks
                                                .toString(),
                                            style: TextStyle(
                                              decoration:
                                                  TextDecoration.underline,
                                              color: Get.isDarkMode
                                                  ? Get.theme.primaryColorDark
                                                  : Colors.black,
                                              fontSize: 30.0,
                                            ),
                                          )
                                        ],
                                      ),
                                    ),
                                  ),
                                ),
                                Expanded(
                                  child: GestureDetector(
                                    onTap: () {
                                      if (isTeacher) {
                                         // Get.toNamed('/teacher/reports/student');
                                         Get.to(() => TeacherReportsStudent(showAppbar: true));
                                      }
                                    },
                                    child: Container(
                                      margin:
                                          EdgeInsets.symmetric(horizontal: 3.0),
                                      padding: EdgeInsets.symmetric(
                                          horizontal: 15.0, vertical: 6.0),
                                      decoration: BoxDecoration(
                                          color: Get.isDarkMode
                                              ? AppTheme.colors.darkTheme2
                                              : Colors.white.withOpacity(0.6),
                                          borderRadius:
                                              BorderRadius.circular(3.0)),
                                      child: Column(
                                        children: [
                                          Container(
                                            margin: EdgeInsets.symmetric(
                                                vertical: 6.0),
                                            padding: EdgeInsets.symmetric(
                                                horizontal: 9.0),
                                            decoration: BoxDecoration(
                                                color: Get.isDarkMode
                                                    ? Colors.black
                                                    : Colors.black
                                                        .withOpacity(0.1),
                                                borderRadius:
                                                    BorderRadius.circular(
                                                        30.0)),
                                            child: Text(
                                              "Quizzes Taken".tr,
                                              maxLines: 1,
                                              overflow: TextOverflow.fade,
                                              softWrap: false,
                                              style: TextStyle(
                                                color: Get.isDarkMode
                                                    ? Get.theme.primaryColorDark
                                                    : Colors.black,
                                                fontSize: 12.0,
                                              ),
                                            ),
                                          ),
                                          Text(
                                            widget.classOverviewTotalData.result
                                                .quizTimes
                                                .toString(),
                                            style: TextStyle(
                                              decoration:
                                                  TextDecoration.underline,
                                              color: Get.isDarkMode
                                                  ? Get.theme.primaryColorDark
                                                  : Colors.black,
                                              fontSize: 30.0,
                                            ),
                                          )
                                        ],
                                      ),
                                    ),
                                  ),
                                ),
                                Expanded(
                                  child: GestureDetector(
                                    onTap: () {
                                      if (isTeacher) {
                                        // Get.toNamed('/teacher/reports/basket');
                                         Get.to(() => TeacherReportsBasket(showAppbar: true));
                                      }
                                    },
                                    child: Container(
                                      margin:
                                          EdgeInsets.symmetric(horizontal: 3.0),
                                      padding: EdgeInsets.symmetric(
                                          horizontal: 21.0, vertical: 6.0),
                                      decoration: BoxDecoration(
                                          color: Get.isDarkMode
                                              ? AppTheme.colors.darkTheme2
                                              : Colors.white.withOpacity(0.6),
                                          borderRadius:
                                              BorderRadius.circular(3.0)),
                                      child: Column(
                                        children: [
                                          Container(
                                            margin: EdgeInsets.symmetric(
                                                vertical: 6.0),
                                            padding: EdgeInsets.symmetric(
                                                horizontal: 9.0),
                                            decoration: BoxDecoration(
                                                color: Get.isDarkMode
                                                    ? Colors.black
                                                    : Colors.black
                                                        .withOpacity(0.1),
                                                borderRadius:
                                                    BorderRadius.circular(
                                                        30.0)),
                                            child: Text(
                                              "Recordings".tr,
                                              maxLines: 1,
                                              overflow: TextOverflow.fade,
                                              softWrap: false,
                                              style: TextStyle(
                                                color: Get.isDarkMode
                                                    ? Get.theme.primaryColorDark
                                                    : Colors.black,
                                                fontSize: 12.0,
                                              ),
                                            ),
                                          ),
                                          Text(
                                            widget.classOverviewTotalData.result
                                                .recordings
                                                .toString(),
                                            style: TextStyle(
                                              decoration:
                                                  TextDecoration.underline,
                                              color: Get.isDarkMode
                                                  ? Get.theme.primaryColorDark
                                                  : Colors.black,
                                              fontSize: 30.0,
                                            ),
                                          )
                                        ],
                                      ),
                                    ),
                                  ),
                                ),
                              ],
                            ),
                            Row(
                              mainAxisAlignment: MainAxisAlignment.start,
                              children: [
                                Expanded(
                                  child: GestureDetector(
                                    onTap: () {
                                      if (isTeacher) {
                                         // Get.toNamed('/teacher/reports/basket');
                                         Get.to(() => TeacherReportsBasket(showAppbar: true));
                                      }
                                    },
                                    child: Container(
                                      margin: EdgeInsets.all(3.0),
                                      padding: EdgeInsets.symmetric(
                                          horizontal: 21.0, vertical: 6.0),
                                      decoration: BoxDecoration(
                                          color: Get.isDarkMode
                                              ? AppTheme.colors.darkTheme2
                                              : Colors.white.withOpacity(0.6),
                                          borderRadius:
                                              BorderRadius.circular(3.0)),
                                      child: Column(
                                        children: [
                                          Container(
                                            margin: EdgeInsets.symmetric(
                                                vertical: 6.0),
                                            padding: EdgeInsets.symmetric(
                                                horizontal: 9.0),
                                            decoration: BoxDecoration(
                                                color: Get.isDarkMode
                                                    ? Colors.black
                                                    : Colors.black
                                                        .withOpacity(0.1),
                                                borderRadius:
                                                    BorderRadius.circular(
                                                        30.0)),
                                            child: Text(
                                              "Writings".tr,
                                              maxLines: 1,
                                              overflow: TextOverflow.fade,
                                              softWrap: false,
                                              style: TextStyle(
                                                color: Get.isDarkMode
                                                    ? Get.theme.primaryColorDark
                                                    : Colors.black,
                                                fontSize: 12.0,
                                              ),
                                            ),
                                          ),
                                          Text(
                                            widget.classOverviewTotalData.result
                                                .writings
                                                .toString(),
                                            style: TextStyle(
                                              decoration:
                                                  TextDecoration.underline,
                                              color: Get.isDarkMode
                                                  ? Get.theme.primaryColorDark
                                                  : Colors.black,
                                              fontSize: 30.0,
                                            ),
                                          )
                                        ],
                                      ),
                                    ),
                                  ),
                                ),
                                Expanded(
                                  flex: 2,
                                  child: Container(),
                                ),
                              ],
                            ),
                          ],
                        )
                      : Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Expanded(
                                  child: GestureDetector(
                                    onTap: () {
                                      if (isTeacher) {
                                          // Get.toNamed('/teacher/reports/student');
                                         Get.to(() => TeacherReportsStudent(showAppbar: true));
                                      }
                                    },
                                    child: Container(
                                      margin: EdgeInsets.all(3.0),
                                      padding: EdgeInsets.symmetric(
                                          horizontal: 21.0, vertical: 6.0),
                                      decoration: BoxDecoration(
                                          color: Get.isDarkMode
                                              ? AppTheme.colors.darkTheme2
                                              : Colors.white.withOpacity(0.6),
                                          borderRadius:
                                              BorderRadius.circular(3.0)),
                                      child: Column(
                                        children: [
                                          Container(
                                            margin: EdgeInsets.symmetric(
                                                vertical: 6.0),
                                            padding: EdgeInsets.symmetric(
                                                horizontal: 9.0),
                                            decoration: BoxDecoration(
                                                color: Get.isDarkMode
                                                    ? Colors.black
                                                    : Colors.black
                                                        .withOpacity(0.1),
                                                borderRadius:
                                                    BorderRadius.circular(
                                                        30.0)),
                                            child: Text(
                                              "Students".tr,
                                              maxLines: 1,
                                              overflow: TextOverflow.fade,
                                              softWrap: false,
                                              style: TextStyle(
                                                color: Get.isDarkMode
                                                    ? Get.theme.primaryColorDark
                                                    : Colors.black,
                                                fontSize: 12.0,
                                              ),
                                            ),
                                          ),
                                          Text(
                                            widget.classOverviewTotalData.result
                                                .studentNum
                                                .toString(),
                                            style: TextStyle(
                                              decoration:
                                                  TextDecoration.underline,
                                              color: Get.isDarkMode
                                                  ? Get.theme.primaryColorDark
                                                  : Colors.black,
                                              fontSize: 30.0,
                                            ),
                                          )
                                        ],
                                      ),
                                    ),
                                  ),
                                ),
                                Expanded(
                                  child: GestureDetector(
                                    onTap: () {
                                      if (isTeacher) {
                                         Get.to(() => TeacherReportsHomework(
                                            showAppbar: true));
                                        // Get.toNamed(
                                        //     '/teacher/reports/homework');
                                      }
                                    },
                                    child: Container(
                                      margin: EdgeInsets.all(3.0),
                                      padding: EdgeInsets.symmetric(
                                          horizontal: 18.0, vertical: 6.0),
                                      decoration: BoxDecoration(
                                          color: Get.isDarkMode
                                              ? AppTheme.colors.darkTheme2
                                              : Colors.white.withOpacity(0.6),
                                          borderRadius:
                                              BorderRadius.circular(3.0)),
                                      child: Column(
                                        children: [
                                          Container(
                                            margin: EdgeInsets.symmetric(
                                                vertical: 6.0),
                                            padding: EdgeInsets.symmetric(
                                                horizontal: 9.0),
                                            decoration: BoxDecoration(
                                                color: Get.isDarkMode
                                                    ? Colors.black
                                                    : Colors.black
                                                        .withOpacity(0.1),
                                                borderRadius:
                                                    BorderRadius.circular(
                                                        30.0)),
                                            child: Text(
                                              "Homework".tr,
                                              maxLines: 1,
                                              overflow: TextOverflow.fade,
                                              softWrap: false,
                                              style: TextStyle(
                                                color: Get.isDarkMode
                                                    ? Get.theme.primaryColorDark
                                                    : Colors.black,
                                                fontSize: 12.0,
                                              ),
                                            ),
                                          ),
                                          Text(
                                            widget.classOverviewTotalData.result
                                                .assignments
                                                .toString(),
                                            style: TextStyle(
                                              decoration:
                                                  TextDecoration.underline,
                                              color: Get.isDarkMode
                                                  ? Get.theme.primaryColorDark
                                                  : Colors.black,
                                              fontSize: 30.0,
                                            ),
                                          )
                                        ],
                                      ),
                                    ),
                                  ),
                                ),
                                Expanded(
                                  child: GestureDetector(
                                    onTap: () {
                                      if (isTeacher) {
                                         // Get.toNamed('/teacher/reports/student');
                                         Get.to(() => TeacherReportsStudent(showAppbar: true));
                                      }
                                    },
                                    child: Container(
                                      margin: EdgeInsets.all(3.0),
                                      padding: EdgeInsets.symmetric(
                                          horizontal: 21.0, vertical: 6.0),
                                      decoration: BoxDecoration(
                                          color: Get.isDarkMode
                                              ? AppTheme.colors.darkTheme2
                                              : Colors.white.withOpacity(0.6),
                                          borderRadius:
                                              BorderRadius.circular(3.0)),
                                      child: Column(
                                        children: [
                                          Container(
                                            margin: EdgeInsets.symmetric(
                                                vertical: 6.0),
                                            padding: EdgeInsets.symmetric(
                                                horizontal: 9.0),
                                            decoration: BoxDecoration(
                                                color: Get.isDarkMode
                                                    ? Colors.black
                                                    : Colors.black
                                                        .withOpacity(0.1),
                                                borderRadius:
                                                    BorderRadius.circular(
                                                        30.0)),
                                            child: Text(
                                              "Books Read".tr,
                                              maxLines: 1,
                                              overflow: TextOverflow.fade,
                                              softWrap: false,
                                              style: TextStyle(
                                                color: Get.isDarkMode
                                                    ? Get.theme.primaryColorDark
                                                    : Colors.black,
                                                fontSize: 12.0,
                                              ),
                                            ),
                                          ),
                                          Text(
                                            widget.classOverviewTotalData.result
                                                .readTimes
                                                .toString(),
                                            style: TextStyle(
                                              decoration:
                                                  TextDecoration.underline,
                                              color: Get.isDarkMode
                                                  ? Get.theme.primaryColorDark
                                                  : Colors.black,
                                              fontSize: 30.0,
                                            ),
                                          )
                                        ],
                                      ),
                                    ),
                                  ),
                                ),
                                Expanded(
                                  child: GestureDetector(
                                    onTap: () {
                                      if (isTeacher) {
                                         // Get.toNamed('/teacher/reports/student');
                                        Get.to(() => TeacherReportsStudent(showAppbar: true));
                                      }
                                    },
                                    child: Container(
                                      margin:
                                          EdgeInsets.symmetric(horizontal: 3.0),
                                      padding: EdgeInsets.symmetric(
                                          horizontal: 21.0, vertical: 6.0),
                                      decoration: BoxDecoration(
                                          color: Get.isDarkMode
                                              ? AppTheme.colors.darkTheme2
                                              : Colors.white.withOpacity(0.6),
                                          borderRadius:
                                              BorderRadius.circular(3.0)),
                                      child: Column(
                                        children: [
                                          Container(
                                            margin: EdgeInsets.symmetric(
                                                vertical: 6.0),
                                            padding: EdgeInsets.symmetric(
                                                horizontal: 9.0),
                                            decoration: BoxDecoration(
                                                color: Get.isDarkMode
                                                    ? Colors.black
                                                    : Colors.black
                                                        .withOpacity(0.1),
                                                borderRadius:
                                                    BorderRadius.circular(
                                                        30.0)),
                                            child: Text(
                                              "Titles Read".tr,
                                              maxLines: 1,
                                              overflow: TextOverflow.fade,
                                              softWrap: false,
                                              style: TextStyle(
                                                color: Get.isDarkMode
                                                    ? Get.theme.primaryColorDark
                                                    : Colors.black,
                                                fontSize: 12.0,
                                              ),
                                            ),
                                          ),
                                          Text(
                                            widget.classOverviewTotalData.result
                                                .readBooks
                                                .toString(),
                                            style: TextStyle(
                                              decoration:
                                                  TextDecoration.underline,
                                              color: Get.isDarkMode
                                                  ? Get.theme.primaryColorDark
                                                  : Colors.black,
                                              fontSize: 30.0,
                                            ),
                                          )
                                        ],
                                      ),
                                    ),
                                  ),
                                ),
                              ],
                            ),
                            Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Expanded(
                                  child: GestureDetector(
                                    onTap: () {
                                      if (isTeacher) {
                                         // Get.toNamed('/teacher/reports/student');
                                         Get.to(() => TeacherReportsStudent(showAppbar: true));
                                      }
                                    },
                                    child: Container(
                                      margin:
                                          EdgeInsets.symmetric(horizontal: 3.0),
                                      padding: EdgeInsets.symmetric(
                                          horizontal: 15.0, vertical: 6.0),
                                      decoration: BoxDecoration(
                                          color: Get.isDarkMode
                                              ? AppTheme.colors.darkTheme2
                                              : Colors.white.withOpacity(0.6),
                                          borderRadius:
                                              BorderRadius.circular(3.0)),
                                      child: Column(
                                        children: [
                                          Container(
                                            margin: EdgeInsets.symmetric(
                                                vertical: 6.0),
                                            padding: EdgeInsets.symmetric(
                                                horizontal: 9.0),
                                            decoration: BoxDecoration(
                                                color: Get.isDarkMode
                                                    ? Colors.black
                                                    : Colors.black
                                                        .withOpacity(0.1),
                                                borderRadius:
                                                    BorderRadius.circular(
                                                        30.0)),
                                            child: Text(
                                              "Quizzes Taken".tr,
                                              maxLines: 1,
                                              overflow: TextOverflow.fade,
                                              softWrap: false,
                                              style: TextStyle(
                                                color: Get.isDarkMode
                                                    ? Get.theme.primaryColorDark
                                                    : Colors.black,
                                                fontSize: 12.0,
                                              ),
                                            ),
                                          ),
                                          Text(
                                            widget.classOverviewTotalData.result
                                                .quizTimes
                                                .toString(),
                                            style: TextStyle(
                                              decoration:
                                                  TextDecoration.underline,
                                              color: Get.isDarkMode
                                                  ? Get.theme.primaryColorDark
                                                  : Colors.black,
                                              fontSize: 30.0,
                                            ),
                                          )
                                        ],
                                      ),
                                    ),
                                  ),
                                ),
                                Expanded(
                                  child: GestureDetector(
                                    onTap: () {
                                      if (isTeacher) {
                                         // Get.toNamed('/teacher/reports/basket');
                                         Get.to(() => TeacherReportsBasket(showAppbar: true));
                                      }
                                    },
                                    child: Container(
                                      margin:
                                          EdgeInsets.symmetric(horizontal: 3.0),
                                      padding: EdgeInsets.symmetric(
                                          horizontal: 21.0, vertical: 6.0),
                                      decoration: BoxDecoration(
                                          color: Get.isDarkMode
                                              ? AppTheme.colors.darkTheme2
                                              : Colors.white.withOpacity(0.6),
                                          borderRadius:
                                              BorderRadius.circular(3.0)),
                                      child: Column(
                                        children: [
                                          Container(
                                            margin: EdgeInsets.symmetric(
                                                vertical: 6.0),
                                            padding: EdgeInsets.symmetric(
                                                horizontal: 9.0),
                                            decoration: BoxDecoration(
                                                color: Get.isDarkMode
                                                    ? Colors.black
                                                    : Colors.black
                                                        .withOpacity(0.1),
                                                borderRadius:
                                                    BorderRadius.circular(
                                                        30.0)),
                                            child: Text(
                                              "Recordings".tr,
                                              maxLines: 1,
                                              overflow: TextOverflow.fade,
                                              softWrap: false,
                                              style: TextStyle(
                                                color: Get.isDarkMode
                                                    ? Get.theme.primaryColorDark
                                                    : Colors.black,
                                                fontSize: 12.0,
                                              ),
                                            ),
                                          ),
                                          Text(
                                            widget.classOverviewTotalData.result
                                                .recordings
                                                .toString(),
                                            style: TextStyle(
                                              decoration:
                                                  TextDecoration.underline,
                                              color: Get.isDarkMode
                                                  ? Get.theme.primaryColorDark
                                                  : Colors.black,
                                              fontSize: 30.0,
                                            ),
                                          )
                                        ],
                                      ),
                                    ),
                                  ),
                                ),
                                Expanded(
                                  child: GestureDetector(
                                    onTap: () {
                                      if (isTeacher) {
                                         // Get.toNamed('/teacher/reports/basket');
                                         Get.to(() => TeacherReportsBasket(showAppbar: true));
                                      }
                                    },
                                    child: Container(
                                      margin: EdgeInsets.all(3.0),
                                      padding: EdgeInsets.symmetric(
                                          horizontal: 21.0, vertical: 6.0),
                                      decoration: BoxDecoration(
                                          color: Get.isDarkMode
                                              ? AppTheme.colors.darkTheme2
                                              : Colors.white.withOpacity(0.6),
                                          borderRadius:
                                              BorderRadius.circular(3.0)),
                                      child: Column(
                                        children: [
                                          Container(
                                            margin: EdgeInsets.symmetric(
                                                vertical: 6.0),
                                            padding: EdgeInsets.symmetric(
                                                horizontal: 9.0),
                                            decoration: BoxDecoration(
                                                color: Get.isDarkMode
                                                    ? Colors.black
                                                    : Colors.black
                                                        .withOpacity(0.1),
                                                borderRadius:
                                                    BorderRadius.circular(
                                                        30.0)),
                                            child: Text(
                                              "Writings".tr,
                                              maxLines: 1,
                                              overflow: TextOverflow.fade,
                                              softWrap: false,
                                              style: TextStyle(
                                                color: Get.isDarkMode
                                                    ? Get.theme.primaryColorDark
                                                    : Colors.black,
                                                fontSize: 12.0,
                                              ),
                                            ),
                                          ),
                                          Text(
                                            widget.classOverviewTotalData.result
                                                .writings
                                                .toString(),
                                            style: TextStyle(
                                              decoration:
                                                  TextDecoration.underline,
                                              color: Get.isDarkMode
                                                  ? Get.theme.primaryColorDark
                                                  : Colors.black,
                                              fontSize: 30.0,
                                            ),
                                          )
                                        ],
                                      ),
                                    ),
                                  ),
                                ),
                                Expanded(
                                  child: Container(),
                                )
                              ],
                            ),
                          ],
                        ))
              : Text("No data"),
        ],
      )),
    );
  }
}
